﻿// owner 蒋家伟

#pragma once
#include "IElementBasicInfomation.h"

// 序列化
#include "DBSchemaObject.h"
#include "ObjectReflectDeclare.h"
#include "DataSerializeDefine.h"
#include "UniqueId.h"

namespace jsdk
{
    class IElement;
    class ElementBasicInfomation :public DBSchemaObject, public IElementBasicInfomation
    {
    public:
        OBJECT_SERIALIZE_DECLARE_DERIVED2(jsdk, ElementBasicInfomation, L"{FEC71084-E160-467D-83FC-E509E9D77F0B}", DBSchemaObject, IElementBasicInfomation)
            DATA_CUSTOM(IElement*, pOwnerElement)
            DATA(std::wstring, objectName)
            DATA(std::wstring, debugInfo)
            DATA(jsdk::Bool, isTemporary)
            DATA(jsdk::UniqueId, typeUid)
            DATA(ElementId, ownerId)

    public:
        static OwnerPtr<ElementBasicInfomation> create();
        void setOwnerElement(IElement* pOwnerElement);
        void setElementId(const ElementId& elementId);
        void setTypeUid(const UniqueId& typeUid);
        void setIsTemporary(bool isTemp);

    public:
        // 继承IElementBasicInfomation
        virtual void setName(const std::wstring& name) override { setobjectName__(name); };
        virtual void setDebugInfo(const std::wstring& debugInfo) override { setdebugInfo__(debugInfo); };
        virtual const std::wstring& getName() const override { return getobjectName__(); };
        virtual bool isTemporaryObject() const override { return getisTemporary__(); };
        virtual const std::wstring& getDebugInfo() const override { return getdebugInfo__(); };
        virtual const IElement* getOwnerElement() const override { return getpOwnerElement__(); };
        virtual IElement* getOwnerElement() override { return getpOwnerElementFW__(); };
        virtual const ElementId& getElementId() const override { return getownerId__(); };
        virtual const UniqueId& getTypeUid() const override { return gettypeUid__(); };

    private:
        // 继承DBSchemaObject
        virtual const IElement* getTopLevelElement() const { return getOwnerElement(); };
    };
}
